#ifndef TOPIC_H
#define TOPIC_H

#include <QVector>
#include <QString>
#include <QStringList>
#include <QVariant>
#include <QObject>
#include <QDateTime>
#include <QAbstractListModel>
#include "profile.h"

class User{
    QMap<QString, QString> properties;
    public:
	QString getProperty(QString name) const;
	void setProperty(QString name, QString property);
};

//just a pure data-set
class Article:public baseOnProfile{
    public:
	User * author;
	QString board;
	QString topic;
	QString id;
	QString time;
	QString title;
	QString content;
	QString quote;
	QString signature;
	bool isNew;
	bool isImportant;
	virtual QString display(void);
	virtual QString reply();
};

class Topic : public baseOnProfile{
    Q_OBJECT
    public:
	QString board;			// What board it belongs to
	QString id;			// The id of this topic
	QString name;			// The name of this topic
	QString time;			// Last time we check this topic
	int reply;			// How many replies in this topic
	bool favorite;			// Is it my favorite topic??
	QVector<Article *> articlePool;	// A pool store the links to the articles
    public:
	~Topic();
	Topic(QString boardId = 0, QString newId = 0 , QString newName = 0 , int newPop = 0);
	virtual QString display(void);	// When we just want a simple show
    public slots:
	virtual void refreshMe() {};
    signals:
	void refreshFinished(bool error);
	void newStatus(int statusCode, QString explain);
    protected:
	// 将对应的帖子添加至本话题
	bool addArticle(Article * article);
};

class topicModel : public QAbstractListModel {
    ///this MODEL maybe only to show the Topic list...?
    Q_OBJECT
    public:
	topicModel(QObject *parent = 0);
	void setTopic(Topic * newTopic);
	int rowCount (const QModelIndex &index) const;
	QVariant data(const QModelIndex &index, int role) const;
	QModelIndex index(int row, int column, const QModelIndex &parent) const;
    private:
	Topic * topic;
    public slots:
	void refresh(bool);
};

#endif
